<template>
  <div class="container">
    <!-- 内容部分 -->
    <div class="operate">
      <slot></slot>
      <div style="margin-left: auto">
        <el-select
          v-model="value"
          size="small"
          placeholder="Select"
          style="width: 120px"
        >
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </div>
      <slot name="op"></slot>
    </div>
    <div class="content" :style="{ maxHeight: item.h * 40 - 80 + 'px' }">
      <Chart :spec="spec" />
    </div>
  </div>
</template>

<script setup lang="ts">
  /**
   * @description 业务组件 -- 报告数据统计
   */
  import { ref } from "vue";
  import Chart from "./Chart.vue";
  defineProps(["item"]);
  const spec = {
    type: "bar",
    data: [
      {
        id: "barData",
        values: [
          {
            State: "WY",
            Age: "Under 5 Years",
            Population: 25635,
          },
          {
            State: "WY",
            Age: "5 to 13 Years",
            Population: 1890,
          },
          {
            State: "WY",
            Age: "14 to 17 Years",
            Population: 9314,
          },
          {
            State: "DC",
            Age: "Under 5 Years",
            Population: 30352,
          },
          {
            State: "DC",
            Age: "5 to 13 Years",
            Population: 20439,
          },
          {
            State: "DC",
            Age: "14 to 17 Years",
            Population: 10225,
          },
          {
            State: "VT",
            Age: "Under 5 Years",
            Population: 38253,
          },
          {
            State: "VT",
            Age: "5 to 13 Years",
            Population: 42538,
          },
          {
            State: "VT",
            Age: "14 to 17 Years",
            Population: 15757,
          },
          {
            State: "ND",
            Age: "Under 5 Years",
            Population: 51896,
          },
          {
            State: "ND",
            Age: "5 to 13 Years",
            Population: 67358,
          },
          {
            State: "ND",
            Age: "14 to 17 Years",
            Population: 18794,
          },
          {
            State: "AK",
            Age: "Under 5 Years",
            Population: 72083,
          },
          {
            State: "AK",
            Age: "5 to 13 Years",
            Population: 85640,
          },
          {
            State: "AK",
            Age: "14 to 17 Years",
            Population: 22153,
          },
        ],
      },
    ],
    xField: "State",
    yField: "Population",
    seriesField: "Age",
    stack: true,
    legends: {
      visible: true,
      orient: "top",
      position: "start",
    },
    bar: {
      // The state style of bar
      state: {
        hover: {
          stroke: "#000",
          lineWidth: 1,
        },
      },
    },
  };

  const value = ref("");

  const options = [
    {
      value: "Option1",
      label: "全部人员",
    },
    {
      value: "Option2",
      label: "部分人员",
    },
  ];
</script>

<style scoped lang="scss">
  .container {
    user-select: none;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0px 10px 10px;
    font-size: 14px;
    color: #999;
    .content {
      flex: 1;
      display: flex;
      flex-direction: column;
      margin-top: 10px;
      overflow: hidden;
    }
  }

  .content-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
  }
  .content-item-main {
    display: flex;
    flex-direction: column;
  }
  .operate {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
  }
</style>
